<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>百万级QPS系统防护指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
            min-height: 100vh;
            color: #e0e0e0;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .card-gradient {
            background: rgba(255, 255, 255, 0.05);
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }
        
        .code-block {
            background: rgba(0, 0, 0, 0.3);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            overflow-x: auto;
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
            border-left: 4px solid #667eea;
            padding: 1rem;
            margin: 1rem 0;
            border-radius: 0 8px 8px 0;
        }
        
        .metric-card {
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid rgba(255, 255, 255, 0.1);
            transition: all 0.3s ease;
        }
        
        .metric-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
            border-color: rgba(102, 126, 234, 0.5);
        }
        
        pre {
            margin: 0;
            padding: 1rem;
            font-size: 0.875rem;
            line-height: 1.5;
            color: #e0e0e0;
        }
        
        code {
            font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
        }
        
        .mermaid {
            background: transparent;
            text-align: center;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            margin-top: -0.2rem;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        .timeline-item {
            position: relative;
            padding-left: 40px;
            margin-bottom: 2rem;
        }
        
        .timeline-item::before {
            content: '';
            position: absolute;
            left: 10px;
            top: 8px;
            width: 12px;
            height: 12px;
            background: #667eea;
            border-radius: 50%;
            box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
        }
        
        .timeline-item::after {
            content: '';
            position: absolute;
            left: 15px;
            top: 20px;
            width: 2px;
            height: calc(100% + 1rem);
            background: rgba(102, 126, 234, 0.3);
        }
        
        .timeline-item:last-child::after {
            display: none;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="relative overflow-hidden">
        <div class="absolute inset-0 bg-gradient-to-b from-purple-900/20 to-transparent"></div>
        <div class="container mx-auto px-6 py-20 relative z-10">
            <div class="text-center max-w-4xl mx-auto">
                <h1 class="text-5xl md:text-7xl font-bold mb-6">
                    <span class="hero-gradient">百万级QPS</span>
                    <span class="text-white">系统防护指南</span>
                </h1>
                <p class="text-xl md:text-2xl text-gray-300 mb-8 leading-relaxed">
                    当凌晨三点的告警声响起，系统接口QPS暴增至百万级，<br>
                    这份经过实战检验的防护策略，将是你的救命稻草
                </p>
                <div class="flex flex-wrap justify-center gap-4 mt-12">
                    <div class="metric-card rounded-lg px-6 py-4">
                        <div class="text-3xl font-bold text-purple-400">1M+</div>
                        <div class="text-sm text-gray-400">QPS峰值</div>
                    </div>
                    <div class="metric-card rounded-lg px-6 py-4">
                        <div class="text-3xl font-bold text-blue-400">99.99%</div>
                        <div class="text-sm text-gray-400">可用性</div>
                    </div>
                    <div class="metric-card rounded-lg px-6 py-4">
                        <div class="text-3xl font-bold text-green-400">&lt;100ms</div>
                        <div class="text-sm text-gray-400">响应时间</div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Crisis Scene -->
    <section class="container mx-auto px-6 py-16">
        <div class="card-gradient rounded-2xl p-8 md:p-12">
            <div class="prose prose-lg max-w-none">
                <p class="text-lg leading-relaxed">
                    <span class="drop-cap">凌</span>晨三点，你的手机突然响起告警声，系统接口QPS暴增至百万级，服务器CPU使用率飙升至100%，响应时间从毫秒级飙升至秒级，用户投诉如雪片般涌来。这不是演习，而是真实发生在许多互联网公司的噩梦。无论是恶意攻击还是业务爆发，百万级QPS的冲击都能让脆弱的系统瞬间崩溃。
                </p>
            </div>
            <div class="mt-8">
                <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1749791922619-d36d88cc-4857-4844-b080-b4d2a1b3db14.png" 
                     alt="系统监控面板" 
                     class="rounded-lg shadow-2xl w-full">
            </div>
        </div>
    </section>

    <!-- Attack Analysis -->
    <section class="container mx-auto px-6 py-16">
        <h2 class="text-3xl font-bold mb-12 section-title">
            <i class="fas fa-shield-alt mr-3 text-purple-400"></i>理解高并发攻击的本质
        </h2>
        
        <div class="grid md:grid-cols-3 gap-6 mb-12">
            <div class="card-gradient rounded-xl p-6">
                <div class="text-purple-400 text-3xl mb-4">
                    <i class="fas fa-network-wired"></i>
                </div>
                <h3 class="text-xl font-semibold mb-3">DDoS攻击</h3>
                <p class="text-gray-300">通过大量请求耗尽系统资源，使正常用户无法访问服务</p>
            </div>
            <div class="card-gradient rounded-xl p-6">
                <div class="text-blue-400 text-3xl mb-4">
                    <i class="fas fa-robot"></i>
                </div>
                <h3 class="text-xl font-semibold mb-3">CC攻击</h3>
                <p class="text-gray-300">针对应用层的攻击，反复请求特定接口造成服务瘫痪</p>
            </div>
            <div class="card-gradient rounded-xl p-6">
                <div class="text-green-400 text-3xl mb-4">
                    <i class="fas fa-spider"></i>
                </div>
                <h3 class="text-xl font-semibold mb-3">爬虫攻击</h3>
                <p class="text-gray-300">大规模数据爬取，消耗带宽和计算资源</p>
            </div>
        </div>

        <!-- Attack Flow Diagram -->
        <div class="card-gradient rounded-xl p-8">
            <h3 class="text-xl font-semibold mb-6">攻击流程分析</h3>
            <div class="mermaid">
                graph LR
                    A[攻击者] -->|发起攻击| B[僵尸网络]
                    B -->|分布式请求| C[CDN/网关]
                    C -->|穿透防护| D[应用服务器]
                    D -->|资源耗尽| E[系统崩溃]
                    
                    style A fill:#f96,stroke:#333,stroke-width:2px
                    style E fill:#f66,stroke:#333,stroke-width:2px
                    style C fill:#6a6,stroke:#333,stroke-width:2px
            </div>
        </div>
    </section>

    <!-- Defense Strategies -->
    <section class="container mx-auto px-6 py-16">
        <h2 class="text-3xl font-bold mb-12 section-title">
            <i class="fas fa-layer-group mr-3 text-purple-400"></i>多层防护体系架构
        </h2>

        <div class="space-y-8">
            <!-- Frontend Protection -->
            <div class="timeline-item">
                <div class="card-gradient rounded-xl p-8">
                    <h3 class="text-2xl font-semibold mb-6 text-purple-400">
                        <i class="fas fa-desktop mr-2"></i>前端防护策略
                    </h3>
                    
                    <div class="grid md:grid-cols-2 gap-6 mb-6">
                        <div class="highlight-box">
                            <h4 class="font-semibold mb-2">验证码与人机识别</h4>
                            <p class="text-sm text-gray-300">滑动验证、行为分析、图形识别等多种验证方式</p>
                        </div>
                        <div class="highlight-box">
                            <h4 class="font-semibold mb-2">客户端频率限制</h4>
                            <p class="text-sm text-gray-300">防抖、节流、请求合并等前端优化策略</p>
                        </div>
                    </div>

                    <div class="code-block">
                        <pre><code class="language-javascript">// 滑动验证码实现示例
function initSliderCaptcha() {
    const slider = document.getElementById('slider');
    const track = document.getElementById('track');
    let startX = 0;
    let moveX = 0;
    
    slider.addEventListener('mousedown', function(e) {
        startX = e.clientX;
        document.addEventListener('mousemove', moveHandler);
        document.addEventListener('mouseup', upHandler);
    });
    
    function moveHandler(e) {
        moveX = e.clientX - startX;
        if(moveX < 0) moveX = 0;
        if(moveX > track.clientWidth - slider.clientWidth) 
            moveX = track.clientWidth - slider.clientWidth;
        slider.style.transform = `translateX(${moveX}px)`;
    }
}</code></pre>
                    </div>
                </div>
            </div>

            <!-- Gateway Protection -->
            <div class="timeline-item">
                <div class="card-gradient rounded-xl p-8">
                    <h3 class="text-2xl font-semibold mb-6 text-blue-400">
                        <i class="fas fa-server mr-2"></i>网关层防护措施
                    </h3>
                    
                    <div class="grid md:grid-cols-2 gap-6 mb-6">
                        <div class="highlight-box">
                            <h4 class="font-semibold mb-2">IP限流策略</h4>
                            <p class="text-sm text-gray-300">基于IP的访问频率限制，防止单点攻击</p>
                        </div>
                        <div class="highlight-box">
                            <h4 class="font-semibold mb-2">WAF配置</h4>
                            <p class="text-sm text-gray-300">Web应用防火墙，拦截各种Web攻击</p>
                        </div>
                    </div>

                    <div class="code-block">
                        <pre><code class="language-nginx"># Nginx限流配置
http {
    # 定义限流区域
    limit_req_zone $binary_remote_addr zone=req_zone:10m rate=10r/s